home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / SOUND / MP3CONV.ZIP / !MP3Conv / c / sound-aix < prev    next >
Text File  |  1997-02-19  |  2KB  |  65 lines

  1. #include "common.h"
  2. #include "sound.h"
  3.  
  4. int sound_init(int audiofd, layer *info, int stereo) {
  5.     /* Initialize audio device */
  6.     audio_init      init;
  7.     audio_control control;
  8.     audio_change  change;
  9.     int          samplefrq = (int)(s_freq[info->version]
  10.              [info->sampling_frequency] * 1000.0);
  11.  
  12.     init.srate = samplefrq * 1000;
  13.     init.bits_per_sample = 16;
  14.     init.mode = PCM;
  15.     init.channels = stereo;
  16.     init.flags = BIG_ENDIAN | FIXED;
  17.     init.operation = PLAY;
  18.     if (ioctl(audiofd, AUDIO_INIT, &init)!= 0) {
  19.     perror("Error initializing ACPA");
  20.     exit(1);
  21.     }
  22.  
  23.     control.ioctl_request = AUDIO_CHANGE;
  24.     control.request_info = &change;
  25.     control.position = 0;
  26.  
  27.     change.dev_info = 0;
  28.     change.input = AUDIO_IGNORE;
  29.     change.output = OUTPUT_1;
  30.     change.monitor = AUDIO_IGNORE;
  31.     /* change.volume = 0x7fff0000; */
  32.     change.volume = 0x5fff0000;
  33.     change.volume_delay = 0;
  34.     change.balance = 0x3fff0000;
  35.     change.balance_delay = 0;
  36.     change.treble = AUDIO_IGNORE;
  37.     change.bass = AUDIO_IGNORE;
  38.     change.pitch = AUDIO_IGNORE;
  39.          
  40.     if (ioctl(audiofd, AUDIO_CONTROL, &control) != 0) {
  41.     perror( "Error changing ACPA parameters");
  42.     exit(1);
  43.     }
  44.  
  45.     control.ioctl_request = AUDIO_START;
  46.  
  47.     if (ioctl(audiofd, AUDIO_CONTROL, &control) != 0) {
  48.     perror("Error starting ACPA");
  49.     exit(1);
  50.     }
  51.     return 0;
  52. }
  53.  
  54. int sound_open() {
  55.     return(open("/dev/paud0/1", O_WRONLY));
  56. }
  57.  
  58. int sound_close(int audiofd) {
  59.     return(close(audiofd));
  60. }
  61.  
  62. int sound_write(int audiofd, const void *buffer, size_t count) {
  63.     return(write(audiofd, buffer, count));
  64. }
  65.